<?php 

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE data_user SET template=%s WHERE id=%s",
                       GetSQLValueString($_POST['template'], "text"),
                       GetSQLValueString($row_admin['id'], "int"));

  mysql_select_db($database_konek, $konek);
  $Result1 = mysql_query($updateSQL, $konek) or die(mysql_error());
}


?>

<?php
function list_template($folder)
{
    if(is_dir($folder))
    {
        if($handel = opendir($folder))
        {
    //tampilkan semua file dalam folder kecuali
            while(($berkas = readdir($handel)) !== false)
            {
				


				if(strlen($berkas)>8)
				$judul=substr($berkas,0,6)." ..";
				else $judul=$berkas;
				if($berkas<>".." and $berkas<>"." and $berkas<>"uploadzip.php"){
        echo '<div style="margin:5px; float:left" align="center"><a href="pluginview.php?p='.$berkas.'"><img src="'.$folder.$berkas.'/image.png" width="100px" height="100px"  /><br />'.$judul.'</a><br />
<form action="" method="post" name="form1" id="form1">
<input type="submit" value="Terapkan" >
<input type="hidden" name="template" value="'.$berkas.$row_admin['template'].'" />
<input type="hidden" name="MM_update" value="form1" />
</form>
</div>';


				}
            }
            closedir($handel);
        }
    }
}
//cara menggunakan
?>
<div class="block">
<div class="block-title">
<h2><i class="fa fa-th-large"></i> Template Diterapkan</h2>
</div><div style="height:220px"><img src="../g-template/<?php echo $row_admin['template']; ?>/image.png" width="200px" height="200px" style="margin-bottom:10px; margin-right:20px; float:left" /><h2><?php echo $row_admin['template']; ?></h2>
  <a href="#">Sesuaikan Template</a></div></div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php
list_template("../g-template/");
?></td>
  </tr>
</table>
